//
//  MCWithdrawRecDeltailViewController.m
//  TLYL
//2018年08月28日16:04:10
//  Created by miaocai on 2017/7/10.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCWithdrawRecDeltailViewController.h"
#import "MCRechargeHeaderView.h"
#import "MCBankTableViewController.h"
#import "MCSelectedBottomView.h"
#import "NSString+Helper.h"
#import "MCUserMoneyModel.h"
#import "MCWithdrawAPIModel.h"
#import "MCMineInfoModel.h"
#import "MCDataTool.h"
#import "MCBankCardListModel.h"
#import "MCBankModel.h"
#import "MCWithDrawInfoModel.h"
#import "ExceptionView.h"
#import "MCPopAlertView.h"
#import "MCGetIPAdress.h"
#import "MCTools.h"
#import "MCGetAutoCodeModel.h"
#import "MCGetUserGroupDrawConfigModel.h"
#import "MCWithdrawListView.h"

#define UILABEL_LINE_SPACE 5
#define UILABEL_Kern_SPACE 0.1
@interface MCWithdrawRecDeltailViewController ()
<
MCSelectedBottomDelegate,NSURLSessionDelegate
>
typedef void(^MCWithdrawRecDeltailViewControllerCompeletion)(BOOL result, NSDictionary *data );
typedef void(^MCMineAddBankCardViewControllerCompeletion)(BOOL result, id data );

@property (nonatomic,strong)MCRechargeHeaderView * headerView;

@property (nonatomic,strong)UIScrollView *bases;
@property (nonatomic,strong)UIButton *withdrawBtn;
@property (nonatomic,strong)MCBankModel *selectModel;
@property (nonatomic,strong)MCUserMoneyModel * money_model;
@property (nonatomic,strong)MCWithdrawAPIModel * apiModel;
@property (nonatomic,strong)MCMineInfoModel *mineInfoModel;
@property (nonatomic,strong)MCWithDrawInfoModel * withDrawInfoModel;
@property (nonatomic,strong)MCGetAutoCodeModel *getAutoCodeModel;
@property (nonatomic,strong)MCGetUserGroupDrawConfigModel * getUserGroupDrawConfigModel;

@property (strong, nonatomic)  UIView * upview;
@property (weak,  nonatomic)  UITextField *bankTextFeild;
@property (weak,  nonatomic)  UITextField *moneyTextField;
@property (weak,  nonatomic)  UITextField *passwordTextField;
@property (strong, nonatomic)  UILabel * feeMoneyLabel;

//提现最小值
@property (nonatomic,assign)double DrawMinMoney;
//提现最大值
@property (nonatomic,assign)double DrawMaxMoney;
//提款时间
@property (nonatomic,strong)UILabel * infoLabel;
//提款规则
@property (nonatomic,strong)UILabel * withdrawalRule;
//重要提示
@property (nonatomic,strong)UILabel * importantNotice;
//提款次数
@property (nonatomic,strong)UILabel * withdrawNumber;
//提款时间
@property (nonatomic,strong)UILabel * TimeLabel;
//单笔限额
@property (nonatomic,strong)UILabel *limitMoney;
@property (nonatomic,strong)MCBankCardListModel  * bankCardListModel;
@property (nonatomic,strong)MCBankModel * defualtbankModel;
@property(nonatomic, strong)ExceptionView * exceptionView;
@property(nonatomic, strong)UITextField * authCodeTextField;

//图标验证码
@property (nonatomic,strong) UILabel *authCodeLab;

@property(nonatomic, strong)UIView *btmView;
@property(nonatomic, strong)MCWithdrawListView * withdrawListView;
@property(nonatomic, assign)NSInteger T ;
@property(nonatomic, strong)NSDictionary * dic1;
@property(nonatomic, strong)NSDictionary * dic2;
@property(nonatomic, strong)MCGetUserGroupDrawConfigDataModel  * groupDrawConfigDataModel;

@end

@implementation MCWithdrawRecDeltailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self  setProperty];
    [self  setUpUI];
    __weak __typeof__ (self) wself = self;
    [self GetBankCardList:^(BOOL result, id data) {
        NSArray * arr = data;
        [wself setDefualtbankModelWithArr:arr];
    }];
    
    [self loadDrawWithInfoData:YES];
    [self authAPIID];
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [BKIndicationView dismiss];
}

-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden=NO;
    self.navigationController.navigationBar.translucent = NO;
    [self loadMineInfoModelData];
    [self reloadUserMoney];
}

#pragma mark==================setProperty======================
-(void)setProperty{
    self.navigationItem.title = @"提款";
    self.view.backgroundColor = RGB(231, 231, 231);
    _selectModel=[[MCBankModel alloc]init];
}

#pragma mark==================UI======================
- (void)setUpUI{
    
    [self.view addSubview:self.bases];
    
    [self createHeaderView];
   
    [self createUpView];
    
    _withdrawBtn=[[UIButton alloc]init];
    [self setFooter:_withdrawBtn];

    UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyboard:)];
    singleTapGesture.numberOfTapsRequired = 1;
    singleTapGesture.cancelsTouchesInView = NO;
    [self.bases  addGestureRecognizer:singleTapGesture];

    self.withdrawListView = [[MCWithdrawListView alloc]init];
    [self.bases addSubview: self.withdrawListView];
    
}

#pragma mark-headerView
-(void)createHeaderView{
    [self.bases addSubview:self.headerView];
    self.headerView.frame=CGRectMake(0, 0, G_SCREENWIDTH, [MCRechargeHeaderView computeHeight:nil]);
    
    __weak __typeof__ (self) wself = self;
    
    self.headerView.shuaXinBlock = ^{
        //刷新余额
        [BKIndicationView showInView:wself.view];
        MCUserMoneyModel * money_model=[MCUserMoneyModel sharedMCUserMoneyModel];
        [money_model refreashDataAndShow];
        wself.money_model=money_model;
        money_model.callBackSuccessBlock = ^(id manager) {
            [BKIndicationView dismiss];
            wself.money_model.FreezeMoney=manager[@"FreezeMoney"];
            wself.money_model.LotteryMoney=manager[@"LotteryMoney"];
            wself.headerView.yuElab.text = [MCMathUnits GetMoneyShowNum:manager[@"LotteryMoney"]];
        };
        
        money_model.callBackFailedBlock = ^(id manager, NSString *errorCode) {
            [BKIndicationView dismiss];
        };
    };
    
}

#pragma mark-createUpView
-(void)createUpView{

    [self.bases addSubview:self.upview];
    self.upview.frame=CGRectMake(10, [MCRechargeHeaderView computeHeight:nil]+10, G_SCREENWIDTH-20, 250);

    UITextField * bankTextFeild=[[UITextField alloc]init];
    _bankTextFeild=bankTextFeild;
    _bankTextFeild.userInteractionEnabled=NO;
    [self setTitle:@"到款账户" andTextField:bankTextFeild WithPlaceholder:@"" and:UIKeyboardTypeDefault andIndex:0 andBackView:self.upview];
    
    UITextField * moneyTextField=[[UITextField alloc]init];
    _moneyTextField=moneyTextField;
    _moneyTextField.tag=1001;
    [self setTitle:@"提款金额" andTextField:moneyTextField WithPlaceholder:@"" and:UIKeyboardTypeDecimalPad andIndex:1 andBackView:self.upview];
    
    UITextField * passwordTextField=[[UITextField alloc]init];
    _passwordTextField=passwordTextField;
    _passwordTextField.secureTextEntry = YES;
    [self setTitle:@"资金密码" andTextField:passwordTextField WithPlaceholder:@"请输入您的资金密码" and:UIKeyboardTypeDefault andIndex:2 andBackView:self.upview];
    
    [self.upview addSubview:self.authCodeTextField];
    
    [self.upview addSubview:self.authCodeLab];
    
    [self.authCodeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.authCodeTextField.mas_centerY);
        make.height.equalTo(@35);
        make.right.equalTo(self.view.mas_right).offset(-20);
        make.width.equalTo(@(MC_REALVALUE(75)));
    }];
    
    UIView * line=[[UIView alloc]init];
    line.backgroundColor=RGB(213,213,213);
    line.frame=CGRectMake(10, 50*4, G_SCREENWIDTH-20-10, 0.6);
    [self.upview addSubview:line];
    
    [self.upview addSubview:self.feeMoneyLabel];
    self.feeMoneyLabel.text=@"手续费：0元(剩余0次免手续费)";
    self.feeMoneyLabel.frame = CGRectMake(10, 200, G_SCREENWIDTH-40, 50);
    
}

- (NSString *)timeStr:(int)drawTime{
    
        if(drawTime>=0 && drawTime < 6){
            return [NSString stringWithFormat:@"凌晨%d:00",drawTime];
        }else if (drawTime>=6 && drawTime < 12){
            return [NSString stringWithFormat:@"上午%d:00",drawTime];

        }else if (drawTime>=12 && drawTime < 18){
            return [NSString stringWithFormat:@"下午%d:00",drawTime];
   
        }else{
            return [NSString stringWithFormat:@"晚上%d:00",drawTime];
        }
}

#pragma mark - gesture actions
- (void)closeKeyboard:(UITapGestureRecognizer *)recognizer {
    [self.view endEditing:YES];
}

-(void)setFooter:(UIButton *)btn{
    
    btn.frame=CGRectMake(10, [MCRechargeHeaderView computeHeight:nil]+10+50*5+10, G_SCREENWIDTH-20, 40);
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn setTitle:@"立即提款" forState:UIControlStateNormal];
    btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    btn.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    btn.backgroundColor=MC_THEME_COLOR;
    [self.bases addSubview:btn];
    [btn addTarget:self action:@selector(withdrawBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    btn.layer.cornerRadius=5.0;
    btn.clipsToBounds=YES;

}

#pragma mark-setUpBottomInfoMsg
- (void)setUpBottomInfoMsg{
    
    [_btmView removeFromSuperview];
    
    UIView *btmView = [[UIView alloc] init];
    [self.bases addSubview:btmView];
    _btmView=btmView;
    [btmView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(_withdrawBtn.mas_bottom).offset(40);
        make.height.equalTo(@(200));
    }];
    
    MCMineInfoModel *mineInfoModel = [MCMineInfoModel sharedMCMineInfoModel];
    CGFloat fontSize = 12 , L_WIDTH = 70;
    
    /*
     * 提款时间
     */
    UILabel *withdrawTimeLabel = [[UILabel alloc] init];
    withdrawTimeLabel.text = @"提款时间:";
    withdrawTimeLabel.textColor = RGB(0,0,0);
    [btmView addSubview:withdrawTimeLabel];
    withdrawTimeLabel.font = [UIFont systemFontOfSize:fontSize];
    [withdrawTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(btmView).offset(10);
        make.width.equalTo(@(L_WIDTH));
    }];
    
    UILabel *TimeLabel = [[UILabel alloc] init];
    TimeLabel.font = [UIFont systemFontOfSize:fontSize];
    NSString *DrawBeginTime = mineInfoModel.DrawBeginTime;
    NSString *DrawEndTime = mineInfoModel.DrawEndTime;
    if ([DrawBeginTime isEqualToString:DrawEndTime]) {
        TimeLabel.text = @"全天24小时";
    } else {
        TimeLabel.text = [NSString stringWithFormat:@"%@~%@", [self timeStr:[DrawEndTime intValue]],[self timeStr:[DrawBeginTime intValue]]];
    }
    TimeLabel.textColor = RGB(136,136,136);
    [btmView addSubview:TimeLabel];
    self.TimeLabel = TimeLabel;
    [TimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(withdrawTimeLabel.mas_right);
        make.top.equalTo(withdrawTimeLabel);
    }];
    
    /*
     * 单笔限额
     */
    UILabel *limitMoneyLabel = [[UILabel alloc] init];
    limitMoneyLabel.textColor = RGB(0,0,0);
    limitMoneyLabel.text = @"单笔限额:";
    [btmView addSubview:limitMoneyLabel];
    limitMoneyLabel.font = [UIFont systemFontOfSize:fontSize];
    [limitMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btmView).offset(10);
        make.top.equalTo(withdrawTimeLabel.mas_bottom).offset(10);
        make.width.equalTo(@(L_WIDTH));
    }];
    
    UILabel *limitMoney = [[UILabel alloc] init];
    limitMoney.text = @"加载中...";
    limitMoney.textColor = RGB(136,136,136);
    [btmView addSubview:limitMoney];
    limitMoney.font = [UIFont systemFontOfSize:fontSize];
    _limitMoney=limitMoney;
    [limitMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(limitMoneyLabel.mas_right);
        make.top.equalTo(limitMoneyLabel);
    }];
    _limitMoney.text=[NSString stringWithFormat:@"%@~%@元",mineInfoModel.DrawMinMoney,mineInfoModel.DrawMaxMoney];
    
    /*
     * 提款次数
     */
    UILabel *withdrawNumberLab = [[UILabel alloc] init];
    withdrawNumberLab.textColor = RGB(0,0,0);
    [btmView addSubview:withdrawNumberLab];
    withdrawNumberLab.font = [UIFont systemFontOfSize:fontSize];
    [withdrawNumberLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btmView).offset(10);
        make.top.equalTo(limitMoneyLabel.mas_bottom).offset(10);
        make.width.equalTo(@(L_WIDTH));
    }];
    
    UILabel *withdrawNumber = [[UILabel alloc] init];
    withdrawNumber.font = [UIFont systemFontOfSize:fontSize];
    withdrawNumber.textColor = RGB(136,136,136);
    [btmView addSubview:withdrawNumber];
    self.withdrawNumber = withdrawNumber;
    [withdrawNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(withdrawNumberLab.mas_right);
        make.top.equalTo(withdrawNumberLab);
    }];
    
    /*
     * 提款次数
     */
    if ([mineInfoModel.DrawCount isEqualToString:@"0"]||mineInfoModel.DrawCount.length<1) {
        withdrawNumberLab.text=@"";
        withdrawNumber.text=@"";
        [withdrawNumberLab mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(btmView).offset(10);
            make.top.equalTo(limitMoneyLabel.mas_bottom).offset(0);
            make.width.equalTo(@(L_WIDTH));
        }];
    }else{
        withdrawNumberLab.text = @"提款次数:";
        withdrawNumber.text = [NSString stringWithFormat:@"%@次/日", mineInfoModel.DrawCount];
    }
    
    /*
     * 重要提示
     */
    UILabel *importantNoticeLabel = [[UILabel alloc] init];
    importantNoticeLabel.textColor = RGB(0,0,0);
    [btmView addSubview:importantNoticeLabel];
    importantNoticeLabel.font = [UIFont systemFontOfSize:fontSize];
    [importantNoticeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btmView).offset(10);
        make.top.equalTo(withdrawNumberLab.mas_bottom).offset(10);
        make.width.equalTo(@(70));
    }];
    
    UILabel *importantNotice = [[UILabel alloc] init];
    self.importantNotice = importantNotice;
    importantNotice.numberOfLines = 0 ;
    importantNotice.font = [UIFont systemFontOfSize:fontSize];
    importantNotice.textColor = RGB(136,136,136);
    [btmView addSubview:importantNotice];
    [importantNotice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(importantNoticeLabel.mas_right);
        make.right.equalTo(self.view.mas_right).offset(-10);
        make.top.equalTo(importantNoticeLabel);
    }];
    if ([self.withDrawInfoModel.VerificationCardType isEqualToString:@"0"]) {
        [importantNoticeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(btmView).offset(10);
            make.top.equalTo(withdrawNumberLab.mas_bottom).offset(0);
            make.width.equalTo(@(70));
        }];
    }else{
        NSString *str = self.withDrawInfoModel.TimeSpanse;
        if ([str isEqualToString:@""] || str == nil||[str containsString:@"null"]) {
            self.withDrawInfoModel.TimeSpanse = @"0";
        }
        importantNoticeLabel.text = @"重要提示:";
        importantNotice.text = [NSString stringWithFormat:@"绑定银行卡%@小时后才能进行提款",self.withDrawInfoModel.TimeSpanse];
        
    }
    
    /*
     * 无手续费隐藏规则说明
     */
    UILabel *infoGuizeLabel = [[UILabel alloc] init];
    infoGuizeLabel.textColor = RGB(0,0,0);
    [btmView addSubview:infoGuizeLabel];
    infoGuizeLabel.font = [UIFont systemFontOfSize:fontSize];
    [infoGuizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btmView).offset(10);
        make.width.equalTo(@(70));
        make.top.equalTo(importantNoticeLabel.mas_bottom).offset(10);
    }];
    
    UILabel *withdrawalRule = [[UILabel alloc] init];
    withdrawalRule.numberOfLines = 0 ;
    withdrawalRule.font = [UIFont systemFontOfSize:fontSize];
    withdrawalRule.textColor = RGB(136,136,136);
    self.withdrawalRule = withdrawalRule;
    [btmView addSubview:withdrawalRule];
    [withdrawalRule mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(infoGuizeLabel.mas_right);
        make.right.equalTo(self.view.mas_right).offset(-10);
        make.top.equalTo(infoGuizeLabel);
    }];
    
    NSString *DrawFeeMoenyType = [NSString stringWithFormat:@"%@",self.withDrawInfoModel.DrawFeeMoenyType];
    if ([DrawFeeMoenyType isEqualToString:@"0"]) {
        infoGuizeLabel.text = @"";
        withdrawalRule.text=@"";
    }else{
        if ([self.withDrawInfoModel.DrawFeeMoenyType isEqualToString:@"0"]) {
            withdrawalRule.hidden = YES;
        } else if([self.withDrawInfoModel.DrawFeeMoenyType isEqualToString:@"1"]){
            
            withdrawalRule.hidden = NO;
            
            if ([self.withDrawInfoModel.CappingMoney isEqualToString:@"0"]) {
                infoGuizeLabel.text = @"规则说明:";
                withdrawalRule.text = [NSString stringWithFormat:@"每天提款前%@次免费，第%d次开始收取手续费",self.withDrawInfoModel.ExemptFeeMoneyCount,([self.withDrawInfoModel.ExemptFeeMoneyCount intValue] + 1)];
            }else{
                infoGuizeLabel.text = @"规则说明:";
                withdrawalRule.text = [NSString stringWithFormat:@"每天提款前%@次免费，第%d次开始收取手续费，单次手续费%@元封顶",self.withDrawInfoModel.ExemptFeeMoneyCount,([self.withDrawInfoModel.ExemptFeeMoneyCount intValue] + 1),self.withDrawInfoModel.CappingMoney];
                
            }
            
        }else if([self.withDrawInfoModel.DrawFeeMoenyType isEqualToString:@"2"]){
            infoGuizeLabel.text = @"规则说明:";
            withdrawalRule.hidden = NO;
            withdrawalRule.text = [NSString stringWithFormat:@"每天提款前%@次免费，第%d次开始收取手续费",self.withDrawInfoModel.ExemptFeeMoneyCount,([self.withDrawInfoModel.ExemptFeeMoneyCount intValue] + 1)];
        }
    }
    
    [self.withdrawListView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(10);
        make.right.equalTo(self.view.mas_right).offset(-10);
        make.top.equalTo(withdrawalRule.mas_bottom).offset(10);
        make.height.mas_equalTo([MCWithdrawListView computeHeight:self.groupDrawConfigDataModel.CollectMoneyList]);
    }];
    
    if ([MCWithdrawListView computeHeight:self.groupDrawConfigDataModel.CollectMoneyList]>200) {
        self.bases.contentSize = CGSizeMake(G_SCREENWIDTH - MC_REALVALUE(26), G_SCREENHEIGHT+[MCWithdrawListView computeHeight:self.groupDrawConfigDataModel.CollectMoneyList]);
    }
}

#pragma  mark-caculateFeeMoney
-(NSString * )caculateFeeMoney{
    
    NSString * jinE=_moneyTextField.text;
    
    //新绑定卡多久后可提款
    NSString * TimeSpanse = [NSString stringWithFormat:@"%@",self.withDrawInfoModel.TimeSpanse];
    if ([TimeSpanse containsString:@"null"]||TimeSpanse.length<1) {
        TimeSpanse=@"0";
    }
    
    //提款手续费方式 (0无手续费1比例2固定金额)
    NSString *DrawFeeMoenyType = [NSString stringWithFormat:@"%@",self.withDrawInfoModel.DrawFeeMoenyType];
    //用户当天提款次数
    NSString * UserDrawCountDay = [NSString stringWithFormat:@"%@",self.withDrawInfoModel.UserDrawCountDay] ;
    //免手续费次数
    NSString *  ExemptFeeMoneyCount = [NSString stringWithFormat:@"%@",self.withDrawInfoModel.ExemptFeeMoneyCount] ;
    //封顶金额
    NSString *  CappingMoney = [NSString stringWithFormat:@"%@",self.withDrawInfoModel.CappingMoney] ;
    
    
    NSString * FeeMoney =@"0";
    
    if (([UserDrawCountDay integerValue]+1)>[ExemptFeeMoneyCount integerValue] ) {
        
        //无手续费
        if ([DrawFeeMoenyType isEqualToString:@"0"]) {
            
            FeeMoney=@"0";
            
            //比例
        }else if([DrawFeeMoenyType isEqualToString:@"1"]){
            
            double F = [self.withDrawInfoModel.CollectMoney doubleValue]*[jinE doubleValue]/100.0;
            
            
            if ([CappingMoney doubleValue]<0.001) {
                
            }else{
                if (F > [CappingMoney doubleValue]) {
                    F = [CappingMoney doubleValue];
                }
            }
            FeeMoney=[MCMathUnits stringWithDecimalNumber:F];
            //固定金额
        }else if([DrawFeeMoenyType isEqualToString:@"2"]){
            
            FeeMoney = GetRealSNum(self.withDrawInfoModel.CollectMoney);
            
        }
    }else{
        FeeMoney = @"0";
        
    }
    return FeeMoney;
}

#pragma  mark-提款
- (void)withdrawBtnClick:(UIButton *)sender {

    if (!self.moneyTextField.text||[self.moneyTextField.text isEqualToString:@""]) {
        [SVProgressHUD showErrorWithStatus:@"请输入提款金额！"];
        return;
    }

    if (!self.passwordTextField.text||[self.passwordTextField.text isEqualToString:@""]) {
        [SVProgressHUD showErrorWithStatus:@"请输入资金密码！"];
        return;
    }
    
    NSString * jinE=_moneyTextField.text;
    NSString * password=_passwordTextField.text;
    if ([jinE isEqualToString:@"0"]) {
        [SVProgressHUD showInfoWithStatus:@"提款金额不能为0!"];
        return;
    }
    //UserRealName	是	String	用户真实姓名
    //DrawingsMoney	是	String	提款金额
    //PayPassWord	是	String	提款密码（资金密码）
    MCUserMoneyModel * money_model=[MCUserMoneyModel sharedMCUserMoneyModel];
    double cccc = [jinE doubleValue] - [money_model.LotteryMoney doubleValue];
    if (cccc>0.0001) {
        [SVProgressHUD showInfoWithStatus:@"账户余额不足，不可提款!"];
        return;
    }
    
    if (_authCodeTextField.text.length<1) {
        [SVProgressHUD showInfoWithStatus:@"请输入验证码!"];
        return;
    }

    if ([jinE doubleValue]>_DrawMaxMoney||[jinE doubleValue]<_DrawMinMoney) {
        [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"提现范围%f-%f元",_DrawMinMoney,_DrawMaxMoney]];
        return;
    }
    __weak __typeof(self)wself = self;

    if (_defualtbankModel==nil||_defualtbankModel.CreateTime.length<1) {
        [self GetBankCardList:^(BOOL result, id data) {
            NSArray * arr = data;
            [wself setDefualtbankModelWithArr:arr];
        }];
        return;
    }
    
    [BKIndicationView showInView:self.view];
    [self loadMCMineInfoData:^(BOOL result, NSDictionary *data) {
       
        MCMineInfoModel *mineInfoModel =[MCMineInfoModel sharedMCMineInfoModel];
        
        //新绑定卡多久后可提款
        NSString * TimeSpanse = [NSString stringWithFormat:@"%@",self.withDrawInfoModel.TimeSpanse];
        if ([TimeSpanse containsString:@"null"]||TimeSpanse.length<1) {
            TimeSpanse=@"0";
        }

        NSString * FeeMoney = [self caculateFeeMoney];
        if (_defualtbankModel.CreateTime.length<1) {
            _defualtbankModel.CreateTime=@"";
        }
        NSString *UserRealName = [NSString stringWithFormat:@"%@",mineInfoModel.UserRealName];
//        UserRealName    是    String    用户真实姓名
//        DrawingsMoney    是    String    提款金额
//        PayPassWord    是    String    提款密码（资金密码）
//        FeeMoney    是    String    手续费金额
//        SecCode    是    String    验证码
        NSDictionary * dic=@{
                             @"UserRealName":UserRealName,
                             @"DrawingsMoney":jinE,
                             @"PayPassWord":password,
                             @"FeeMoney":FeeMoney,
                             @"CreateTime":_defualtbankModel.CreateTime,
                             @"TimeSpanse":TimeSpanse,
                             @"SecCode":_authCodeTextField.text
                             };
        MCWithdrawAPIModel  * apiModel = [[MCWithdrawAPIModel alloc]initWithDic:dic];
        self.apiModel = apiModel;
        [apiModel refreashDataAndShow];
        apiModel.callBackFailedBlock = ^(ApiBaseManager *manager, NSString *errorCode) {
            [BKIndicationView dismiss];

                NSString * responseMessage=[NSString stringWithFormat:@"%@",manager.responseMessage];
            if ((![responseMessage containsString:@"null"]) && (![responseMessage containsString:@"nil"])&& responseMessage.length>0) {
                [SVProgressHUD showInfoWithStatus:responseMessage withComplete:^{
                    [wself loadDrawWithInfoData:NO];
                }];
            }else{
                [wself loadDrawWithInfoData:NO];
            }
        };
        apiModel.callBackSuccessBlock = ^(id manager) {
            [BKIndicationView dismiss];
            [wself loadDrawWithInfoData:YES];
            
            //提现成功   清空输入框
            wself.moneyTextField.text=@"";
            wself.passwordTextField.text=@"";
            wself.authCodeTextField.text=@"";
            
            // 刷新用户金额
            [wself reloadUserMoney];
            
            //刷新验证码
            [wself authAPIID];
            
            ApiBaseManager *manage=manager;
            if (manager) {
                
                if (manage.ResponseRawData) {
                    NSDictionary * dic = manage.ResponseRawData;
                    NSString * Num = [NSString stringWithFormat:@"%@",dic[@"Num"]];
                    if (Num.length>0&&(![Num containsString:@"null"])) {
                        [wself performSelector:@selector(delayMethod:) withObject:Num afterDelay:0.05];
                    }
                }
            
            }
        };
    }];
}


-(void)delayMethodloadDrawWithInfoData{
    [self loadDrawWithInfoData:NO];
}
-(void)delayMethod:(NSString * )noti{
    [self SuccessToDo:noti];
}

-(void)SuccessToDo:(NSString *)noti{
    
    NSString * str_noti = [NSString stringWithFormat:@"前方%@人取款中...",noti];
    MCPopAlertView *mcAlertView = [[MCPopAlertView alloc] initWithType:MCPopAlertTypeTZRequest_Success Title:@"提款成功" message:str_noti leftBtn:@"我知道了" rightBtn:nil];
    mcAlertView.msgLbl.textColor=RGB(102, 102, 102);
    mcAlertView.resultIndex = ^(NSInteger index){
        //回调---处理一系列动作x
        
        if (index==2) {
            
        }
        
    };
    [mcAlertView showXLAlertView];
}

#pragma mark - ===========load data=============
#pragma mark-loadData
-(void)loadMineInfoModelData{
    
    [self refreashData];
    
    __weak __typeof(self)wself = self;
    
    MCMineInfoModel *mineInfo_model = [MCMineInfoModel sharedMCMineInfoModel];
    self.mineInfoModel = mineInfo_model;
    [mineInfo_model refreashDataAndShow];
    mineInfo_model.callBackSuccessBlock = ^(id manager) {
        wself.mineInfoModel=[MCMineInfoModel mj_objectWithKeyValues:manager];
        [wself refreashData];
    };
}

#pragma mark -authAPIID
- (void)authAPIID{
    WS(weakSelf);
    self.authCodeLab.text = @"重试";
    MCGetAutoCodeModel * getAutoCodeModel = [[MCGetAutoCodeModel alloc] init];
    self.getAutoCodeModel = getAutoCodeModel;
    getAutoCodeModel.type = @"1";
    [getAutoCodeModel refreashDataAndShow];
    getAutoCodeModel.callBackFailedBlock = ^(ApiBaseManager *manager, NSString *errorCode) {
        [SVProgressHUD showInfoWithStatus:manager.responseMessage];
    };
    getAutoCodeModel.callBackSuccessBlock = ^(id manager) {
        NSString *  verification_code = [NSString stringWithFormat:@"%@",manager[@"verification_code"]];
        weakSelf.authCodeLab.text=verification_code;
    };
    
}

#pragma mark - loadMCMineInfoData
-(void)loadMCMineInfoData:(MCWithdrawRecDeltailViewControllerCompeletion)Compeletion{
    
    MCMineInfoModel *mineInfoModel = [MCMineInfoModel sharedMCMineInfoModel];
    self.mineInfoModel = mineInfoModel;
    __weak __typeof__ (self) wself = self;
    [mineInfoModel refreashDataAndShow];
    mineInfoModel.callBackSuccessBlock = ^(id manager) {
        wself.mineInfoModel=[MCMineInfoModel mj_objectWithKeyValues:manager];
        Compeletion(YES,manager);
    };
    
    mineInfoModel.callBackFailedBlock = ^(id manager, NSString *errorCode) {
        Compeletion(NO,nil);
    };
}

#pragma mark -reloadUserMoney
-(void)reloadUserMoney{
    MCUserMoneyModel * money_model=[MCUserMoneyModel sharedMCUserMoneyModel];
    [money_model refreashDataAndShow];
    self.money_model=money_model;
    
    __weak __typeof(self)wself = self;
    
    money_model.callBackSuccessBlock = ^(id manager) {
        
        wself.money_model.FreezeMoney=[NSString stringWithFormat:@"%@",manager[@"FreezeMoney"]];
        wself.money_model.LotteryMoney=[NSString stringWithFormat:@"%@",manager[@"LotteryMoney"]];
        wself.headerView.dataSource=[NSString stringWithFormat:@"%@",manager[@"LotteryMoney"]];
    };
}

#pragma mark -GetBankCardList
-(void)GetBankCardList:(MCMineAddBankCardViewControllerCompeletion)Compeletion{
    
    MCBankCardListModel  * bankCardListModel =[[MCBankCardListModel alloc]init];
    [bankCardListModel refreashDataAndShow];
    self.bankCardListModel=bankCardListModel;
    bankCardListModel.callBackFailedBlock = ^(ApiBaseManager *manager, NSString *errorCode) {
        Compeletion(NO,nil);
    };
    bankCardListModel.callBackSuccessBlock = ^(id manager) {
        Compeletion(YES,manager);
    };
    
}
#pragma mark -loadDrawWithInfoData
- (void)loadDrawWithInfoData:(BOOL)isShow{
    
    if (isShow) {
        [BKIndicationView showInView:self.view];
    }
    MCWithDrawInfoModel *infoModel = [[MCWithDrawInfoModel alloc] init];
    self.withDrawInfoModel = infoModel;
    __weak __typeof__ (self) wself = self;
    
    [infoModel refreashDataAndShow];
    self.T = 0;
    dispatch_group_t group = dispatch_group_create();
    dispatch_queue_t quene = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
    dispatch_group_async(group, quene, ^{
        
        infoModel.callBackSuccessBlock = ^(id manager) {
            //complete task 1-YES
            wself.dic1 = manager;
            wself.T++;
            dispatch_semaphore_signal(semaphore);
        };
        
        infoModel.callBackFailedBlock = ^(id manager, NSString *errorCode) {
            //complete task 1-NO
            dispatch_semaphore_signal(semaphore);
        };
        
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
    });
    
    MCGetUserGroupDrawConfigModel * getUserGroupDrawConfigModel = [[MCGetUserGroupDrawConfigModel alloc] initWithDic:@{}];
    self.getUserGroupDrawConfigModel = getUserGroupDrawConfigModel;
    [getUserGroupDrawConfigModel refreashDataAndShow];
    dispatch_group_async(group, quene, ^{
        getUserGroupDrawConfigModel.callBackSuccessBlock = ^(id manager) {
            //complete task 2-YES
            wself.T++;
            wself.dic2 = manager;
            dispatch_semaphore_signal(semaphore);
        };
        
        getUserGroupDrawConfigModel.callBackFailedBlock = ^(id manager, NSString *errorCode) {
            //complete task 2-NO
            dispatch_semaphore_signal(semaphore);
        };
        
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
    });
    
    dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //通知主线程刷新
        dispatch_async(dispatch_get_main_queue(), ^{
            if (isShow) {
                [BKIndicationView dismiss];
            }
            if (wself.T>1) {
                [wself dealWithDrawInfoData];
            }else{
                wself.exceptionView = [ExceptionView exceptionViewWithType:ExceptionCodeTypeRequestFailed];
//                wself.exceptionView.originY=kStatusBarAndNavigationBarHeight;
                ExceptionViewAction *action = [ExceptionViewAction actionWithType:ExceptionCodeTypeRequestFailed handler:^(ExceptionViewAction *action) {
                    [wself.exceptionView dismiss];
                    wself.exceptionView = nil;
                    [wself loadDrawWithInfoData:YES];
                }];
                [wself.exceptionView addAction:action];
                [wself.exceptionView showInView:wself.view];
            }
        });
    });
}
#pragma mark - ===========Method=============
#pragma mark -refreashData
-(void)refreashData{
    MCMineInfoModel *mineInfo_model = [MCMineInfoModel sharedMCMineInfoModel];
    
    NSString * bank;
    if (mineInfo_model.BankCardNumber.length>4) {
        NSString * bankNumber=[mineInfo_model.BankCardNumber substringFromIndex:mineInfo_model.BankCardNumber.length-4];
        bank=[NSString stringWithFormat:@"%@(尾号%@)",[MCDataTool MC_GetDic_Bank][mineInfo_model.BankCode][@"name"],bankNumber];
    }else{
        bank=[NSString stringWithFormat:@"%@",[MCDataTool MC_GetDic_Bank][mineInfo_model.BankCode][@"name"]];
    }
    
    _bankTextFeild.text=bank;
    
    _moneyTextField.placeholder=[NSString stringWithFormat:@"单笔提款金额范围为：%@-%@元",mineInfo_model.DrawMinMoney,mineInfo_model.DrawMaxMoney];
    
    _DrawMinMoney=[mineInfo_model.DrawMinMoney doubleValue];
    _DrawMaxMoney=[mineInfo_model.DrawMaxMoney doubleValue];
    NSString *DrawBeginTime = mineInfo_model.DrawBeginTime;
    NSString *DrawEndTime = mineInfo_model.DrawEndTime;
    if ([DrawBeginTime isEqualToString:DrawEndTime]) {
        _infoLabel.text = @"取款到账时间为1-5分钟，取款时间为:全天24小时";
    } else {
        _infoLabel.text = [NSString stringWithFormat:@"取款到账时间为1-5分钟，取款时间为:%@~%@", [self timeStr:[DrawEndTime intValue]],[self timeStr:[DrawBeginTime intValue]]];
    }
    [self setLabelSpace:_infoLabel withValue:[NSString stringWithFormat:@"提款到默认银行\n%@",_infoLabel.text] withFont:[UIFont systemFontOfSize:12]];
    _infoLabel.textAlignment=NSTextAlignmentCenter;
}
#pragma mark - textField
-(void)textFieldDidChange:(UITextField *)textField{
    
    if (textField.tag==1001) {
        if (textField.text.length == 1 && [textField.text isEqualToString:@"."]) {
            //            textField.text = @"0.";
            textField.text = @"";
        }
        if (textField.text.length == 1 && [textField.text isEqualToString:@"0"]) {
            //            textField.text = @"0.";
            textField.text = @"";
        }
        NSArray *arr = [textField.text componentsSeparatedByString:@"."];
        
        double max = [textField.text doubleValue];
        if (max>= _DrawMaxMoney) {
            max = _DrawMaxMoney;
            textField.text =[NSString stringWithFormat:@"%.f",_DrawMaxMoney];
        }
        if (arr.count >1) {
            
            NSString *str = arr[1];
            if (str.length > 2) {
                str = [str substringWithRange:NSMakeRange(0, 2)];
            }
            //            textField.text = [NSString stringWithFormat:@"%@.%@",arr[0],str];
            textField.text = [NSString stringWithFormat:@"%@",arr[0]];
            
            NSString * str1=arr[0];
            if ([str1 isEqualToString:[NSString stringWithFormat:@"%.f",_DrawMaxMoney]]) {
                textField.text = [NSString stringWithFormat:@"%.f",_DrawMaxMoney];
            }
        }
        self.feeMoneyLabel.text = [NSString stringWithFormat:@"手续费：%@元(剩余%@次免手续费)",[self caculateFeeMoney],[self getRemainingFreeWithdrawalCount]];
        
    }else if(textField.tag==1002){
        
    }else if(textField.tag==1003){
        
    }
}

-(void)setDefualtbankModelWithArr:(NSArray *)arr{
    
    for (NSDictionary * dic  in arr) {
        if ([[NSString stringWithFormat:@"%@",dic[@"Isdefault"]] isEqualToString:@"1"]) {
            _defualtbankModel = [[MCBankModel alloc]init];
            _defualtbankModel.bankNumer=[NSString stringWithFormat:@"%@",dic[@"CardNumber"]];
            _defualtbankModel.showBankNumber=[MCMathUnits GetBankCardShowNum:dic[@"CardNumber"]];
            _defualtbankModel.Isdefault=[NSString stringWithFormat:@"%@",dic[@"Isdefault"]];
            _defualtbankModel.bankName=dic[@"BranchName"];
            _defualtbankModel.bankId=[NSString stringWithFormat:@"%@",dic[@"ID"]];
            _defualtbankModel.BankCode=[NSString stringWithFormat:@"%@",dic[@"BankCode"]];
            _defualtbankModel.userName=[NSString stringWithFormat:@"%@",dic[@"UserName"]];
            _defualtbankModel.CreateTime=[NSString stringWithFormat:@"%@",dic[@"CreateTime"]];
        }
    }
}

#pragma mark-dealWithDrawInfoData
-(void)dealWithDrawInfoData{
    
    
    
    self.groupDrawConfigDataModel = [MCGetUserGroupDrawConfigDataModel mj_objectWithKeyValues:self.dic2];
    [self setMCWithDrawInfoModel:self.dic1];
    
    self.feeMoneyLabel.text = [NSString stringWithFormat:@"手续费：%@元(剩余%@次免手续费)",[self caculateFeeMoney],[self getRemainingFreeWithdrawalCount]];
    
    self.withdrawListView.FeeMoenyType = self.groupDrawConfigDataModel.FeeMoenyType;
    self.withdrawListView.dataSouce = self.groupDrawConfigDataModel.CollectMoneyList;
    if ([MCWithdrawListView computeHeight:self.groupDrawConfigDataModel.CollectMoneyList]>200) {
        self.bases.contentSize = CGSizeMake(G_SCREENWIDTH - MC_REALVALUE(26), G_SCREENHEIGHT+[MCWithdrawListView computeHeight:self.groupDrawConfigDataModel.CollectMoneyList]);
    }
    
}


#pragma mark-getRemainingFreeWithdrawalCount
-(NSString *)getRemainingFreeWithdrawalCount{
    
    NSInteger ExemptFeeMoneyCount = [self.withDrawInfoModel.ExemptFeeMoneyCount integerValue];
    NSInteger UserDrawCountDay = [self.withDrawInfoModel.UserDrawCountDay integerValue];
    
    NSInteger RemainingFreeWithdrawalCount = ExemptFeeMoneyCount-UserDrawCountDay;
    
    
    if (RemainingFreeWithdrawalCount>0) {
        return [NSString stringWithFormat:@"%ld",(long)RemainingFreeWithdrawalCount];
    }
    return @"0";
    
    
}

-(void)setMCWithDrawInfoModel:(NSDictionary *)dic{
    
    self.withDrawInfoModel.CappingMoney = [NSString stringWithFormat:@"%@",dic[@"CappingMoney"]];
    self.withDrawInfoModel.CollectMoney = [NSString stringWithFormat:@"%@",dic[@"CollectMoney"]];
    self.withDrawInfoModel.DrawFeeMoenyType = [NSString stringWithFormat:@"%@",dic[@"DrawFeeMoenyType"]];
    self.withDrawInfoModel.ExemptFeeMoneyCount = [NSString stringWithFormat:@"%@",dic[@"ExemptFeeMoneyCount"]];
    self.withDrawInfoModel.TimeSpanse = [NSString stringWithFormat:@"%@",dic[@"TimeSpanse"]];
    self.withDrawInfoModel.UserDrawCountDay = [NSString stringWithFormat:@"%@",dic[@"UserDrawCountDay"]];
    self.withDrawInfoModel.VerificationCardType = [NSString stringWithFormat:@"%@",dic[@"VerificationCardType"]];
    [self setUpBottomInfoMsg];
    
}



#pragma mark - ===========Other=============

#pragma mark - 改变验证码
- (void)chageAuthImg{
    
    [self authAPIID];
    
}

#pragma mark==================setter  getter ==================
-(UIScrollView *)bases{
    if (!_bases) {
        _bases = [[UIScrollView alloc] initWithFrame:self.view.bounds];
        _bases.contentSize = CGSizeMake(G_SCREENWIDTH - MC_REALVALUE(26), G_SCREENHEIGHT+200);
    }
    return _bases;
}
-(MCRechargeHeaderView *)headerView{
    if (!_headerView) {
        _headerView =[[MCRechargeHeaderView alloc]init];
    }
    return _headerView;
}

-(UILabel *)authCodeLab{
    if (!_authCodeLab) {
        _authCodeLab = [[UILabel alloc]init];
        //        [upview addSubview:_authCodeLab];
        _authCodeLab.backgroundColor=RGB(214, 214, 214);
        _authCodeLab.font = [UIFont boldSystemFontOfSize:20];
        _authCodeLab.textColor = RGB(40, 40, 40);
        _authCodeLab.clipsToBounds=YES;
        _authCodeLab.layer.cornerRadius=5;
        _authCodeLab.textAlignment=NSTextAlignmentCenter;
        _authCodeLab.userInteractionEnabled = YES;
        [_authCodeLab addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(chageAuthImg)]];
    }
    return _authCodeLab;
}

-(UILabel *)feeMoneyLabel{
    if (!_feeMoneyLabel) {
        _feeMoneyLabel = [[UILabel alloc]init];
        _feeMoneyLabel.backgroundColor=[UIColor clearColor];
        _feeMoneyLabel.font = [UIFont systemFontOfSize:14];
        _feeMoneyLabel.textColor = RGB(40, 40, 40);
        _feeMoneyLabel.textAlignment=NSTextAlignmentLeft;
    }
    return _feeMoneyLabel;
}

-(UITextField *)authCodeTextField{
    if (!_authCodeTextField) {
        _authCodeTextField=[[UITextField alloc]init];
        //    _authCodeTextField.secureTextEntry = YES;
        _authCodeTextField.frame=CGRectMake(10, 3*50+1, 200, 49);
        _authCodeTextField.placeholder=@"请输入验证码";
        _authCodeTextField.borderStyle = UITextBorderStyleNone;
        _authCodeTextField.backgroundColor=[UIColor clearColor];
        _authCodeTextField.font = [UIFont systemFontOfSize:14];
        _authCodeTextField.textColor = RGB(40, 40, 40);
        _authCodeTextField.textAlignment = NSTextAlignmentLeft;
        _authCodeTextField.returnKeyType = UIReturnKeyDone;
        _authCodeTextField.keyboardType = UIKeyboardTypeNumberPad;
        [_authCodeTextField setValue:RGB(190, 190, 190) forKeyPath:@"_placeholderLabel.textColor"];
        [_authCodeTextField setValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];
        [_authCodeTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:(UIControlEventEditingChanged)];
    }
    return _authCodeTextField;
}

-(UIView *)upview{
    if (!_upview) {
        _upview=[[UIView alloc]init];
        _upview.backgroundColor=[UIColor whiteColor];
        _upview.layer.cornerRadius=10;
        _upview.clipsToBounds=YES;
    }
    return _upview;
}

#pragma mark - ===========public=============
#pragma mark - 给UILabel设置行间距和字间距
-(void)setLabelSpace:(UILabel*)label withValue:(NSString*)str withFont:(UIFont*)font {
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
    paraStyle.alignment = NSTextAlignmentCenter;
    paraStyle.lineSpacing = UILABEL_LINE_SPACE; //设置行间距
    paraStyle.hyphenationFactor = 1.0;
    paraStyle.firstLineHeadIndent = 0.0;
    paraStyle.paragraphSpacingBefore = 0.0;
    paraStyle.headIndent = 0;
    paraStyle.tailIndent = 0;
    //设置字间距 NSKernAttributeName:@1.5f
    NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@UILABEL_Kern_SPACE
                          };
    
    NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:str attributes:dic];
    label.attributedText = attributeStr;
}
#pragma mark-
-(void)setTitle:(NSString *)title andTextField:(UITextField*)textField WithPlaceholder:(NSString *)placeholder and:(UIKeyboardType)type andIndex:(int)index andBackView:(UIView *)backView{
    
    CGFloat padding=50;
    
    UILabel * lab=[[UILabel alloc]init];
    [backView addSubview:lab];
    lab.font=[UIFont systemFontOfSize:14];
    lab.text=title;
    lab.textColor=RGB(46,46,46);
    lab.frame=CGRectMake(10, index*padding, 80, padding);
    
    [backView addSubview:textField];
    textField.frame=CGRectMake(80, index*padding, G_SCREENWIDTH-20-100, padding);
    textField.placeholder=placeholder;
    textField.borderStyle = UITextBorderStyleNone;
    textField.backgroundColor=[UIColor clearColor];
    textField.font = [UIFont systemFontOfSize:14];
    textField.textColor = RGB(40, 40, 40);
    textField.textAlignment = NSTextAlignmentLeft;
    textField.returnKeyType = UIReturnKeyDone;
    textField.keyboardType = type;
    [textField setValue:RGB(190, 190, 190) forKeyPath:@"_placeholderLabel.textColor"];
    [textField setValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];
    
    [textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:(UIControlEventEditingChanged)];
    
    if (index<3) {
        UIView * line=[[UIView alloc]init];
        line.backgroundColor=RGB(213,213,213);
        line.frame=CGRectMake(10, padding*(index+1), G_SCREENWIDTH-20-10, 0.6);
        [backView addSubview:line];
    }
}
@end


















